package Entity;

import java.util.*;
import java.io.Serializable;

import Controller.Client;

/**
 * this is the entity of the disabled parking spot. it will set a specific parking spot in a parking lot to be disabled.
 * @author Shahar Shelly
 *
 */
public class DisabledPlace implements Serializable
{
	private static final long serialVersionUID = 7523999933510580143L;
	
	private int pid;
	private int parkingLot;
	public int[] place;
	private String description;
	private Date start=null;
	private Date end=null;
	private static int num=0;
	
	/**
	 * is the constructor. it will set the parking spot to be disabled by the following parameters:
	 * @param p= parking lot number
	 * @param pl= the place to disable.
	 * @param desc= a short description why.
	 */
	public DisabledPlace(int p, int []pl, String desc)
	{
		this.setParkingLot(p);
		this.place=new int[pl.length];
		for(int i=0; i<pl.length; i++)
			place[i]=pl[i];
		this.setDescription(new String(desc));
		this.pid=num;
		num++;
	}
	
	/**
	 * is the validation function. it will only check if the parking lot number is between 1 to 6.
	 * @param p= the parking lot number.
	 * @param pl= the parking spot.
	 * @param desc= a short description why.
	 * @return true or flase if everything is ok.
	 */
	public boolean Validate(int p, int []pl,String desc)
	{
		if(p<1 || p>6)
			return false;
		return true;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public Date getStart() {
		return start;
	}

	public void setStart(Date start) {
		this.start = start;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getParkingLot() {
		return parkingLot;
	}

	public void setParkingLot(int parkingLot) {
		this.parkingLot = parkingLot;
	}
	
	public int getPid() {
		return pid;
	}
	
	public int[] getPlace() {
		return place;
	}
	
	public void setPid(int pid) {
		this.pid = pid;
	}
	public void save()
	{
		Client.saveDisabledPlaceToDB(this);
	}
}
